package com.ls.blog.utils;


import com.ls.blog.common.enums.ResultCode;
import lombok.Data;

/**
 * @program: day20210907
 * @author: lishun
 * @create: 2021-09-07 22:44
 **/
@Data
public class R {

    /**
     * 默认成功
     *
     * @return
     */
    public static <T> Result<T> ok() {
        return new Result<T>(true);
    }

    public static <T> Result<T> ok(T data) {
        return new Result<T>(true, data);
    }

    public static <T> Result<T> ok(ResultCode resultCode) {
        return new Result<T>(true, resultCode);
    }

    public static <T> Result<T> ok(ResultCode resultCode, T data) {
        return new Result<T>(true, resultCode, data);
    }

    /**
     * 默认失败
     */
    public static<T> Result<T> fail() {
        return new Result<T>(false);
    }
    public static<T> Result<T> fail(String message) {
        return new Result<T>(false,message);
    }

    public static<T> Result<T> fail(ResultCode resultCode) {
        return new Result<T>(false, resultCode);
    }
    public static<T> Result<T> fail(ResultCode resultCode,T data) {
        return new Result<T>(false, resultCode,data);
    }



}
